package com.sairobo.base.modules.sys.service.impl;

import com.sairobo.base.common.entity.Page;
import com.sairobo.base.common.entity.Query;
import com.sairobo.base.common.entity.R;
import com.sairobo.base.common.service.CommonService;
import com.sairobo.base.common.utils.CommonUtils;
import com.sairobo.base.modules.sys.entity.SysAttach;
import com.sairobo.base.modules.sys.manager.SysAttachManager;
import com.sairobo.base.modules.sys.service.SysAttachService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 附件表
 *
 * @author admin
 * @email sairobo
 * @url www.sairobo.com
 * @date 2018年1月17日 上午11:21:54
 */
@Service("sysAttachService")
public class SysAttachServiceImpl extends CommonService implements SysAttachService {

	@Autowired
	private SysAttachManager sysAttachManager;

	@Override
	public Page<SysAttach> listSysAttach(Map<String, Object> params) {
		Query query = new Query(params);
		Page<SysAttach> page = new Page<>(query);
		sysAttachManager.listSysAttach(page, query);
		return page;
	}

	@Override
	public R saveSysAttach(SysAttach role) {
		int count = sysAttachManager.saveSysAttach(role);
		return CommonUtils.msg(count);
	}

	@Override
	public R getSysAttachById(Long id) {
		SysAttach sysAttach = sysAttachManager.getSysAttachById(id);
		return CommonUtils.msg(sysAttach);
	}

	@Override
	public R updateSysAttach(SysAttach sysAttach) {
		int count = sysAttachManager.updateSysAttach(sysAttach);
		return CommonUtils.msg(count);
	}

	@Override
	public R batchRemove(Long[] id) {
		int count = sysAttachManager.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

}
